Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Function |checked_neg

std/ops/num::|checked_neg


Usage

|checked_neg<N>(val)

Generics

◻ N: CheckedNeg

Parameters

↳ val: N

Return

Option<N>


Return negation of given value, checking if overflow occurs

This function returns an option containing -val, or none if result cause overflow in data type.